<!DOCTYPE html>
<html lang="en">
<style>
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    input[type=checkbox], input[type=radio] {
        display: inline-block;
    }

    .fileinput-button {
        position: relative;
        display: inline-block;
        overflow: hidden;
    }

    .fileinput-button input{
        position: absolute;
        left: 0px;
        top: 0px;
        opacity: 0;
        -ms-filter: 'alpha(opacity=0)';
    }
</style>
<link href="/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
{include file="Public/head"}

<body data-type="widgets">
<!--<script src="/daterangepicker/jquery-3.2.1.min.js" type="text/javascript"></script>-->
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper" >
        <div class="row-content am-cf">
            <div class="row">

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">添加广告位置</div>
                            <div class="widget-function am-fr">
                                <a href="javascript:;" class="am-icon-cog"></a>
                            </div>
                        </div>
                        <div class="widget-body am-fr">
                            <form id="roleform"  form="submit" class="am-form tpl-form-border-form tpl-form-border-br">
                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">广告位名称 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" name="position_name" id="position_name" value="{$res.position_name}">
                                        <input type="text" id="position_id" value="{$res.position_id}" style="display: none">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">广告位宽度 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text"  oninput = "value=value.replace(/[^\d]/g,'');if(value.length>4)value=value.slice(0,4)" class="tpl-form-input" name="ad_width" id="ad_width" value="{$res.ad_width}">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">广告位高度 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text"  oninput = "value=value.replace(/[^\d]/g,'');if(value.length>4)value=value.slice(0,4)" class="tpl-form-input" name="ad_height" id="ad_height" value="{$res.ad_height}">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">广告位描述 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" name="position_desc" id="position_desc" value="{$res.position_desc}">
                                        <small></small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="col-sm-2 control-label">是否开启 </label>
                                    <div class="am-u-sm-9" id="radio">
                                        {if condition='$res.is_open eq 1'}
                                            <input type="radio" value="1" name="docVlGender" class="am-field-valid" checked> 开启
                                            <input type="radio" value="0" name="docVlGender" class="am-field-valid"> 关闭
                                        {else}
                                        <input type="radio" value="1" name="docVlGender" class="am-field-valid" > 开启
                                        <input type="radio" value="0" name="docVlGender" class="am-field-valid" checked> 关闭
                                        {/if}
                                    </div>
                                </div>





                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <a onclick="javascript:history.back(-1);" ><div class="btn btn-default" type="reset" >返回</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>


                                        <button class="btn btn-info" type="button" onclick="master_add()">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
{include file='Public:validation'}

<script>

    // 提交
    function master_add() {
        var data = new Object();
        data['position_id'] = $('#position_id').val();
        data['position_name'] = $('#position_name').val();
        data['ad_width'] = $('#ad_width').val();
        data['ad_height'] = $('#ad_height').val();
        data['position_desc'] = $('#position_desc').val();
        data['is_open'] = $('#radio input[name="docVlGender"]:checked').val();
        $.ajax({
            url:'position_upd', /*去过那个php文件*/
            type:'POST',  /*提交方式*/
            data:data,
            cache: false,
            dataType: "json",
            success:function(ret){
                if(ret.code != 200){
                    layer.msg(ret.msg, {icon: 2});
                    return false;
                }
                layer.msg(ret.msg, {icon: 1,time:2000},function(){
                    location.href = "{:url('positionList')}";
                });
            }
        })
    }





</script>

</html>